<template>
  <view class="message-card">
    <view class="card-header">
      <view class="card-title">{{ classRoom.className }}</view>
      <view class="card-subtitle">
        <text>老师：{{ classRoom.teacherName }}</text>
      </view>
    </view>
    <view class="card-content">
      <view class="content-item">
        <text class="item-label">课程:</text>
        <text class="item-value">{{ classRoom.subjectName }}</text>
      </view>
      <view class="content-item">
        <text class="item-label">人数:</text>
        <text class="item-value">{{ classRoom.studentNum }}</text>
      </view>
    </view>
    <view class="card-footer">
      <button class="edit-btn" @click="editClassRoom">编辑</button>
    </view>
  </view>
</template>

<script setup lang="ts">
import { defineProps } from 'vue'
import type { ClassRoomItem } from '@/types/classRoom'

const props = defineProps<{
  classRoom: ClassRoomItem
}>()

// 编辑班级信息
const editClassRoom = () => {
  uni.navigateTo({
    url: `/pagesOrgan/class/addOrUpdate?id=${props.classRoom.id}`,
  })
}
</script>
<style scoped lang="scss">
.message-card {
  background-color: $card-bg;
  border-radius: $border-radius;
  box-shadow: $shadow;
  margin: 24rpx;
  overflow: hidden;
  transition: all 0.3s ease;
}

.message-card:active {
  transform: scale(0.98);
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}

.card-header {
  padding: 30rpx 30rpx 20rpx;
  background-color: #f8fafc;
  border-bottom: 1rpx solid $border-color;
}

.card-title {
  font-size: 36rpx;
  font-weight: bold;
  color: $text-main;
  margin-bottom: 10rpx;
}

.card-subtitle {
  font-size: 28rpx;
  color: $text-secondary;
}

.card-content {
  padding: 25rpx 30rpx;
}

.content-item {
  display: flex;
  margin-bottom: 20rpx;
  align-items: center;
}

.content-item:last-child {
  margin-bottom: 0;
}

.item-label {
  width: 180rpx;
  font-size: 28rpx;
  color: $text-tertiary;
}

.item-value {
  flex: 1;
  font-size: 28rpx;
  color: $text-secondary;
  line-height: 1.5;
}

.card-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 20rpx 30rpx;
  background-color: #f8fafc;
  border-top: 1rpx solid $border-color;
}

.edit-btn {
  background-color: $primary-color;
  color: white;
  font-size: 28rpx;
  border-radius: 40rpx;
  height: 70rpx;
  line-height: 70rpx;
  padding: 0 30rpx;
  border: none;

  &:active {
    background-color: #1565c0;
  }
}
</style>
